<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>ES6-ES11 | Jushden的个人博客</title><meta name="author" content="Jushden"><meta name="copyright" content="Jushden"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="ES6-ES11ES6-ES11(ECMAScript)ECMA 是一种脚本程序设计语言 （ES5也指 JavaScript） 解决异步方案1）生成器函数 2）promise 3）async 和 await 的结合 ES6特点1）我们现在在写项目时，无论是 vue 还是 react ，它们所使用的 ECMA 版本都是 ES6 。 2）ES6 版本变动内容最多，加入了许多新的语法特性 。 3）ES6">
<meta property="og:type" content="article">
<meta property="og:title" content="ES6-ES11">
<meta property="og:url" content="https://jushden.gitee.io/2023/07/29/ES6-ES11/index.html">
<meta property="og:site_name" content="Jushden的个人博客">
<meta property="og:description" content="ES6-ES11ES6-ES11(ECMAScript)ECMA 是一种脚本程序设计语言 （ES5也指 JavaScript） 解决异步方案1）生成器函数 2）promise 3）async 和 await 的结合 ES6特点1）我们现在在写项目时，无论是 vue 还是 react ，它们所使用的 ECMA 版本都是 ES6 。 2）ES6 版本变动内容最多，加入了许多新的语法特性 。 3）ES6">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img1.baidu.com/it/u=3255567619,1492410640&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500">
<meta property="article:published_time" content="2023-07-29T09:15:15.866Z">
<meta property="article:modified_time" content="2023-07-29T09:16:14.886Z">
<meta property="article:author" content="Jushden">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img1.baidu.com/it/u=3255567619,1492410640&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500"><link rel="shortcut icon" href="/zhuxiaodong.gitee.io/img/favicon.png"><link rel="canonical" href="https://jushden.gitee.io/2023/07/29/ES6-ES11/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/zhuxiaodong.gitee.io/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/zhuxiaodong.gitee.io/',
  algolia: undefined,
  localSearch: {"path":"/zhuxiaodong.gitee.io/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'ES6-ES11',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-29 17:16:14'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/zhuxiaodong.gitee.io/img/duola.jpeg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/zhuxiaodong.gitee.io/archives/"><div class="headline">文章</div><div class="length-num">12</div></a><a href="/zhuxiaodong.gitee.io/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/zhuxiaodong.gitee.io/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zhuxiaodong.gitee.io/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 生活</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zhuxiaodong.gitee.io/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/music/"><i class="fa-fw fa fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/movies/"><i class="fa-fw fas fa-video"></i><span> 影视</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/links/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于笔者</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500')"><nav id="nav"><span id="blog-info"><a href="/zhuxiaodong.gitee.io/" title="Jushden的个人博客"><span class="site-name">Jushden的个人博客</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zhuxiaodong.gitee.io/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 生活</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zhuxiaodong.gitee.io/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/music/"><i class="fa-fw fa fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/zhuxiaodong.gitee.io/movies/"><i class="fa-fw fas fa-video"></i><span> 影视</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/links/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/zhuxiaodong.gitee.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于笔者</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">ES6-ES11</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-29T09:15:15.866Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-29T09:16:14.886Z" title="更新于 2023-07-29 17:16:14">2023-07-29</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="ES6-ES11"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="ES6-ES11"><a href="#ES6-ES11" class="headerlink" title="ES6-ES11"></a>ES6-ES11</h1><h3 id="ES6-ES11-ECMAScript"><a href="#ES6-ES11-ECMAScript" class="headerlink" title="ES6-ES11(ECMAScript)"></a>ES6-ES11(ECMAScript)</h3><p>ECMA 是一种脚本程序设计语言 （ES5也指 JavaScript）</p>
<h4 id="解决异步方案"><a href="#解决异步方案" class="headerlink" title="解决异步方案"></a>解决异步方案</h4><p>1）生成器函数</p>
<p>2）promise</p>
<p>3）async 和 await 的结合</p>
<h4 id="ES6特点"><a href="#ES6特点" class="headerlink" title="ES6特点"></a>ES6特点</h4><p>1）我们现在在写项目时，无论是 vue 还是 react ，它们所使用的 ECMA 版本都是 ES6 。</p>
<p>2）ES6 版本变动内容最多，加入了许多新的语法特性 。</p>
<p>3）ES6是前端发展趋势，就业必备技能。</p>
<h5 id="语法特点"><a href="#语法特点" class="headerlink" title="语法特点"></a>语法特点</h5><h6 id="let"><a href="#let" class="headerlink" title="let"></a>let</h6><p>1）let 变量不能重复声明 （var可以）。</p>
<p>2）块级作用域，只能在代码块中有效。</p>
<h6 id="const"><a href="#const" class="headerlink" title="const"></a>const</h6><p>1）const 定义常量，一定要赋初始值，常量的值不能修改。</p>
<p>2）一般常量使用大写（潜规则）。</p>
<p>3）块级作用域。</p>
<p>4）对于数组和对象的修改，不算做对常量的修改，不会报错。</p>
<h6 id="变量的解构赋值"><a href="#变量的解构赋值" class="headerlink" title="变量的解构赋值"></a>变量的解构赋值</h6><h6 id="模板字符串-96-96"><a href="#模板字符串-96-96" class="headerlink" title="模板字符串&#96;&#96;"></a>模板字符串&#96;&#96;</h6><p>1）在 ES5 中学过  ‘’   “”,单引和双引，但是  ES6  中的反斜符可以换行写字符串，而单引和双引不行。</p>
<p>2）变量拼接。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line">    <span class="comment">//ES5 是利用加号拼接</span></span><br><span class="line">    <span class="keyword">let</span> a= <span class="string">&#x27;xxx&#x27;</span></span><br><span class="line">    <span class="keyword">let</span> b=a+<span class="string">&#x27;是我好朋友&#x27;</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(b);</span><br><span class="line">    <span class="comment">//现在有了模板字符串</span></span><br><span class="line">    <span class="keyword">let</span> c=<span class="string">`<span class="subst">$&#123;a&#125;</span>是我好朋友`</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(c);</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<h6 id="对象的简化写法"><a href="#对象的简化写法" class="headerlink" title="对象的简化写法"></a>对象的简化写法</h6><p>ES6  允许在大括号里面，直接写入变量和函数，作为对象的属性和方法。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">let name =&#x27;xxx&#x27;</span><br><span class="line">let change=function()&#123;</span><br><span class="line">    console.log(&#x27;zzzz&#x27;);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">const school =&#123;</span><br><span class="line">    name,</span><br><span class="line">    change,</span><br><span class="line">    improve:function()&#123;</span><br><span class="line">        console.log(&#x27;cccc&#x27;);</span><br><span class="line">    &#125;,</span><br><span class="line">    //而在ES6版本中，我们可以将：function删除</span><br><span class="line">    delete()&#123;</span><br><span class="line">        console.log(&#x27;vvv&#x27;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h6 id="箭头函数（重要）"><a href="#箭头函数（重要）" class="headerlink" title="箭头函数（重要）"></a>箭头函数（重要）</h6><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> <span class="title function_">fn</span> = (<span class="params">a,b</span>) =&gt; &#123;</span><br><span class="line">    <span class="keyword">return</span> a+b</span><br><span class="line">&#125;</span><br><span class="line"><span class="title function_">fn</span>(<span class="number">3</span>,<span class="number">4</span>)</span><br></pre></td></tr></table></figure>

<p>1）this  指向问题，静态的，始终指向函数声明时所在作用域下的 this 的值。</p>
<p>利用 call() 方法，可以改变this指向问题，假如两个函数  getName()  ,  getName2()  ,  对于普通函数getName() ， 使用getName.call(school)，就把this指向了school  ，而对于箭头函数getName2()，使用getName2.call(school) 无效，说明this始终指向函数声明时所在作用域下的 this 的值。</p>
<p>2）箭头函数缩写</p>
<p>省略小括号，当形参有且只有一个的时候</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> <span class="title function_">a</span> = n =&gt; &#123;</span><br><span class="line">     <span class="keyword">return</span> n+n</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>省略花括号，当代码体只有一句的时候，此时 return 必须省略 ，而且语句的执行结果就是函数的返回值。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> <span class="title function_">b</span> = n =&gt; n*n</span><br></pre></td></tr></table></figure>

<h6 id="获取实参方式"><a href="#获取实参方式" class="headerlink" title="获取实参方式"></a>获取实参方式</h6><p>ES6  引入  rest  参数，用于获取函数的实参，用来代替 arguments </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line">        <span class="comment">//  ES5 获取实参方式</span></span><br><span class="line">        <span class="keyword">function</span> <span class="title function_">date</span>(<span class="params"></span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="variable language_">arguments</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="title function_">date</span>(<span class="string">&#x27;xxx&#x27;</span>,<span class="string">&#x27;ssss&#x27;</span>,<span class="string">&#x27;qqqq&#x27;</span>)</span><br><span class="line"></span><br><span class="line">        <span class="comment">//  ES6 获取实参方式 rest 参数</span></span><br><span class="line">        <span class="keyword">function</span> <span class="title function_">fn</span>(<span class="params">...args</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(args);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="title function_">fn</span>(<span class="string">&#x27;aaa&#x27;</span>,<span class="string">&#x27;ccc&#x27;</span>,<span class="string">&#x27;ss&#x27;</span>)</span><br><span class="line"></span><br><span class="line">        <span class="comment">//数组的一些API方法 filter some every map</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">//rest 必须放到最后</span></span><br><span class="line">        <span class="keyword">function</span> <span class="title function_">fun</span>(<span class="params">a,b,...args</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(a);</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(b);</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(args);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="title function_">fun</span>(<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>,<span class="number">7</span>)</span><br><span class="line">    &lt;/script&gt;</span><br></pre></td></tr></table></figure>

<h6 id="扩展运算符-…"><a href="#扩展运算符-…" class="headerlink" title="扩展运算符 (…)"></a>扩展运算符 (…)</h6><p>…  扩展运算符能将数组转换为逗号分隔的参数序列</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line">    <span class="comment">//数组的合并</span></span><br><span class="line">    <span class="keyword">const</span> a=[<span class="string">&#x27;zzz&#x27;</span>,<span class="string">&#x27;cc&#x27;</span>,<span class="string">&#x27;sss&#x27;</span>]</span><br><span class="line">    <span class="keyword">const</span> b=[<span class="string">&#x27;aaa&#x27;</span>,<span class="string">&#x27;hhh&#x27;</span>]</span><br><span class="line">    <span class="comment">// const c=a.concat(b)</span></span><br><span class="line">    <span class="keyword">const</span> c=[...a,...b]</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(c);</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<h5 id="Symbol"><a href="#Symbol" class="headerlink" title="Symbol"></a>Symbol</h5><p>ES6引入了一种新的数据类型 Symbol 是一种类似于字符串的数据类型</p>
<h5 id="迭代器（iterator）"><a href="#迭代器（iterator）" class="headerlink" title="迭代器（iterator）"></a>迭代器（iterator）</h5><p>迭代器是一种接口，为各种不同的数据结构提供统一的访问机制。任何数据只要部署 iterator 接口，就可以完成遍历操作。</p>
<p>原生具备 iterator 接口的数据可使用 forof 遍历</p>
<p>forin 遍历和 forof 遍历的区别</p>
<p>forin 前面的变量保存的是键名，而forof 保存的是键值</p>
<h5 id="生成器函数"><a href="#生成器函数" class="headerlink" title="生成器函数"></a>生成器函数</h5><p>生成器函数是ES6 提供的一种异步编程解决方案，语法行为与传统函数完全不同。</p>
<h5 id="Promise"><a href="#Promise" class="headerlink" title="Promise"></a>Promise</h5><p>Promise  是ES6 引入的异步编程的新解决方案。语法上，Promise 是一个构造函数，用来封装异步操作并可以获取其失败或成功的结果。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 实例化 Promise 对象</span></span><br><span class="line">        <span class="keyword">const</span> p= <span class="keyword">new</span> <span class="title class_">Promise</span>(<span class="keyword">function</span>(<span class="params">resolve,reject</span>)&#123;</span><br><span class="line">            <span class="built_in">setTimeout</span>(<span class="keyword">function</span>(<span class="params"></span>)&#123;</span><br><span class="line">                <span class="comment">// 数据库中的用户数据 resolve 代表成功，reject 代表失败</span></span><br><span class="line">                <span class="comment">// let data=&#x27;数据库中的用户数据&#x27;</span></span><br><span class="line">                <span class="keyword">let</span> err=<span class="string">&#x27;数据读取失败&#x27;</span></span><br><span class="line">                <span class="comment">// resolve(data)</span></span><br><span class="line">                <span class="title function_">reject</span>(err)</span><br><span class="line">            &#125;,<span class="number">1000</span>)</span><br><span class="line">        &#125;)</span><br><span class="line">        <span class="comment">// 调用promise对象的then方法,成功打印第一个，失败打印第二个</span></span><br><span class="line">        p.<span class="title function_">then</span>(<span class="keyword">function</span>(<span class="params">value</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(value);</span><br><span class="line">        &#125;,<span class="keyword">function</span>(<span class="params">reason</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">error</span>(reason);</span><br><span class="line">        &#125;)</span><br></pre></td></tr></table></figure>

<h6 id="Promise-封装AJAX-请求"><a href="#Promise-封装AJAX-请求" class="headerlink" title="Promise 封装AJAX 请求"></a>Promise 封装AJAX 请求</h6><p>这样写可以 把 then 方法单独列出来，防止回调地狱</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Promise 封装 AJAX 请求</span></span><br><span class="line">        <span class="keyword">const</span> p= <span class="keyword">new</span> <span class="title class_">Promise</span>(<span class="keyword">function</span>(<span class="params">resolve,reject</span>)&#123;</span><br><span class="line">            <span class="comment">//创建对象</span></span><br><span class="line">            <span class="keyword">const</span> xhr =<span class="keyword">new</span> <span class="title class_">XMLHttpRequest</span>()</span><br><span class="line">            <span class="comment">//初始化，设置请求方法和url</span></span><br><span class="line">            xhr.<span class="title function_">open</span>(<span class="string">&#x27;GET&#x27;</span>,<span class="string">&#x27;http://......?a=100&amp;b=200&amp;c=300&#x27;</span>)</span><br><span class="line">            <span class="comment">//发送</span></span><br><span class="line">            xhr.<span class="title function_">send</span>()</span><br><span class="line">            <span class="comment">// 绑定事件，处理响应结果</span></span><br><span class="line">            xhr.<span class="property">onreadystatechange</span>=<span class="keyword">function</span>(<span class="params"></span>)&#123;</span><br><span class="line">                <span class="comment">//判断</span></span><br><span class="line">                <span class="keyword">if</span>(xhr.<span class="property">readyState</span>===<span class="number">4</span>)&#123;</span><br><span class="line">                    <span class="comment">//判断响应状态码 200-299</span></span><br><span class="line">                    <span class="keyword">if</span>(xhr.<span class="property">status</span>&gt;=<span class="number">200</span>&amp;&amp;xhr.<span class="property">status</span>&lt;<span class="number">300</span>)&#123;</span><br><span class="line">                        <span class="comment">//表示成功</span></span><br><span class="line">                        <span class="title function_">resolve</span>(xhr.<span class="property">response</span>)</span><br><span class="line">                    &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">                        <span class="comment">//表示失败</span></span><br><span class="line">                        <span class="title function_">reject</span>(xhr.<span class="property">status</span>)</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">        <span class="comment">// 调用promise对象的then方法,成功打印第一个，失败打印第二个</span></span><br><span class="line">        p.<span class="title function_">then</span>(<span class="keyword">function</span>(<span class="params">value</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">log</span>(value);</span><br><span class="line">        &#125;,<span class="keyword">function</span>(<span class="params">reason</span>)&#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">error</span>(reason);</span><br><span class="line">        &#125;)</span><br></pre></td></tr></table></figure>

<h6 id="Promise-对象-catch方法"><a href="#Promise-对象-catch方法" class="headerlink" title="Promise  对象 catch方法"></a>Promise  对象 catch方法</h6><p>用来指定promise失败的回调。</p>
<h4 id="ES7新特性"><a href="#ES7新特性" class="headerlink" title="ES7新特性"></a>ES7新特性</h4><p>1）includes  判断数组中是否含有某个元素。等同于 indexof 不过返回结果是一个数字，稍显复杂</p>
<p>2）** 幂运算  比如 2**10&#x3D;1024  等同于  Math.pow(2,10)</p>
<h4 id="ES8新特性"><a href="#ES8新特性" class="headerlink" title="ES8新特性"></a>ES8新特性</h4><h5 id="async-和-await"><a href="#async-和-await" class="headerlink" title="async 和 await"></a>async 和 await</h5><p>async 和 await 两种语法结合可以让异步代码像同步代码一样。</p>
<h5 id="async函数"><a href="#async函数" class="headerlink" title="async函数"></a>async函数</h5><p>1）async函数的返回值为promise对象</p>
<p>2）promise 对象的结果由async 函数执行的返回值决定</p>
<p>只要返回的结果不是一个promise 对象，那么这个函数的返回结果就是一个成功的 promise， 但是如果返回的结果是一个成功的promise 对象，那么这个函数返回的结果就是一个成功的promise；除非 抛出错误 返回的结果是一个失败的 promise </p>
<h5 id="await-函数"><a href="#await-函数" class="headerlink" title="await 函数"></a>await 函数</h5><p>1）await 必须写在  async 函数中（await必须要由async ，但async 可以不需要await）</p>
<p>2）await 右侧的表达式一般为 promise 对象</p>
<p>3）await 返回的是 promise 成功的值</p>
<p>4）await 的promise 失败了，就会抛出异常，需要通过 try…catch 捕获处理</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://jushden.gitee.io">Jushden</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://jushden.gitee.io/2023/07/29/ES6-ES11/">https://jushden.gitee.io/2023/07/29/ES6-ES11/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://jushden.gitee.io" target="_blank">Jushden的个人博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/zhuxiaodong.gitee.io/2023/07/29/Flutter%20%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/" title="Flutter 生命周期"><img class="cover" src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="onerror=null;src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Flutter 生命周期</div></div></a></div><div class="next-post pull-right"><a href="/zhuxiaodong.gitee.io/2023/07/29/cms%E9%A1%B9%E7%9B%AE%E7%9F%A5%E8%AF%86%E7%82%B9%E7%A7%AF%E7%B4%AF/" title="cms项目知识点积累"><img class="cover" src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="onerror=null;src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">cms项目知识点积累</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/zhuxiaodong.gitee.io/img/duola.jpeg" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Jushden</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/zhuxiaodong.gitee.io/archives/"><div class="headline">文章</div><div class="length-num">12</div></a><a href="/zhuxiaodong.gitee.io/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/zhuxiaodong.gitee.io/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/Jushden"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Jushden" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1416201335@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来到朱晓东的博客网站</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#ES6-ES11"><span class="toc-number">1.</span> <span class="toc-text">ES6-ES11</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#ES6-ES11-ECMAScript"><span class="toc-number">1.0.1.</span> <span class="toc-text">ES6-ES11(ECMAScript)</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%A7%A3%E5%86%B3%E5%BC%82%E6%AD%A5%E6%96%B9%E6%A1%88"><span class="toc-number">1.0.1.1.</span> <span class="toc-text">解决异步方案</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ES6%E7%89%B9%E7%82%B9"><span class="toc-number">1.0.1.2.</span> <span class="toc-text">ES6特点</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%AF%AD%E6%B3%95%E7%89%B9%E7%82%B9"><span class="toc-number">1.0.1.2.1.</span> <span class="toc-text">语法特点</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#let"><span class="toc-number">1.0.1.2.1.1.</span> <span class="toc-text">let</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#const"><span class="toc-number">1.0.1.2.1.2.</span> <span class="toc-text">const</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E5%8F%98%E9%87%8F%E7%9A%84%E8%A7%A3%E6%9E%84%E8%B5%8B%E5%80%BC"><span class="toc-number">1.0.1.2.1.3.</span> <span class="toc-text">变量的解构赋值</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E6%A8%A1%E6%9D%BF%E5%AD%97%E7%AC%A6%E4%B8%B2-96-96"><span class="toc-number">1.0.1.2.1.4.</span> <span class="toc-text">模板字符串&#96;&#96;</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E7%9A%84%E7%AE%80%E5%8C%96%E5%86%99%E6%B3%95"><span class="toc-number">1.0.1.2.1.5.</span> <span class="toc-text">对象的简化写法</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0%EF%BC%88%E9%87%8D%E8%A6%81%EF%BC%89"><span class="toc-number">1.0.1.2.1.6.</span> <span class="toc-text">箭头函数（重要）</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96%E5%AE%9E%E5%8F%82%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.1.2.1.7.</span> <span class="toc-text">获取实参方式</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E6%89%A9%E5%B1%95%E8%BF%90%E7%AE%97%E7%AC%A6-%E2%80%A6"><span class="toc-number">1.0.1.2.1.8.</span> <span class="toc-text">扩展运算符 (…)</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Symbol"><span class="toc-number">1.0.1.2.2.</span> <span class="toc-text">Symbol</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%BF%AD%E4%BB%A3%E5%99%A8%EF%BC%88iterator%EF%BC%89"><span class="toc-number">1.0.1.2.3.</span> <span class="toc-text">迭代器（iterator）</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E7%94%9F%E6%88%90%E5%99%A8%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.1.2.4.</span> <span class="toc-text">生成器函数</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Promise"><span class="toc-number">1.0.1.2.5.</span> <span class="toc-text">Promise</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#Promise-%E5%B0%81%E8%A3%85AJAX-%E8%AF%B7%E6%B1%82"><span class="toc-number">1.0.1.2.5.1.</span> <span class="toc-text">Promise 封装AJAX 请求</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#Promise-%E5%AF%B9%E8%B1%A1-catch%E6%96%B9%E6%B3%95"><span class="toc-number">1.0.1.2.5.2.</span> <span class="toc-text">Promise  对象 catch方法</span></a></li></ol></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ES7%E6%96%B0%E7%89%B9%E6%80%A7"><span class="toc-number">1.0.1.3.</span> <span class="toc-text">ES7新特性</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ES8%E6%96%B0%E7%89%B9%E6%80%A7"><span class="toc-number">1.0.1.4.</span> <span class="toc-text">ES8新特性</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#async-%E5%92%8C-await"><span class="toc-number">1.0.1.4.1.</span> <span class="toc-text">async 和 await</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#async%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.1.4.2.</span> <span class="toc-text">async函数</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#await-%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.1.4.3.</span> <span class="toc-text">await 函数</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/zhuxiaodong.gitee.io/2023/07/29/TypeScript%E7%AC%AC%E4%B8%80%E7%AB%A0%EF%BC%9A%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" title="TS入门"><img src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="TS入门"/></a><div class="content"><a class="title" href="/zhuxiaodong.gitee.io/2023/07/29/TypeScript%E7%AC%AC%E4%B8%80%E7%AB%A0%EF%BC%9A%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" title="TS入门">TS入门</a><time datetime="2023-07-29T09:15:15.878Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/zhuxiaodong.gitee.io/2023/07/29/TypeScript%E7%AC%AC%E4%BA%8C%E7%AB%A0%EF%BC%9A%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="TS面向对象"><img src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="TS面向对象"/></a><div class="content"><a class="title" href="/zhuxiaodong.gitee.io/2023/07/29/TypeScript%E7%AC%AC%E4%BA%8C%E7%AB%A0%EF%BC%9A%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="TS面向对象">TS面向对象</a><time datetime="2023-07-29T09:15:15.876Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/zhuxiaodong.gitee.io/2023/07/29/React%E5%85%A8%E5%AE%B6%E6%A1%B6/" title="React全家桶"><img src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="React全家桶"/></a><div class="content"><a class="title" href="/zhuxiaodong.gitee.io/2023/07/29/React%E5%85%A8%E5%AE%B6%E6%A1%B6/" title="React全家桶">React全家桶</a><time datetime="2023-07-29T09:15:15.875Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/zhuxiaodong.gitee.io/2023/07/29/React%E6%89%A9%E5%B1%95/" title="React扩展"><img src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="React扩展"/></a><div class="content"><a class="title" href="/zhuxiaodong.gitee.io/2023/07/29/React%E6%89%A9%E5%B1%95/" title="React扩展">React扩展</a><time datetime="2023-07-29T09:15:15.873Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/zhuxiaodong.gitee.io/2023/07/29/ReactRouter6%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B/" title="React Router 6 快速上手"><img src="https://img1.baidu.com/it/u=3255567619,1492410640&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="this.onerror=null;this.src='/zhuxiaodong.gitee.io/img/404.jpg'" alt="React Router 6 快速上手"/></a><div class="content"><a class="title" href="/zhuxiaodong.gitee.io/2023/07/29/ReactRouter6%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B/" title="React Router 6 快速上手">React Router 6 快速上手</a><time datetime="2023-07-29T09:15:15.871Z" title="发表于 2023-07-29 17:15:15">2023-07-29</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Jushden</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/zhuxiaodong.gitee.io/js/utils.js"></script><script src="/zhuxiaodong.gitee.io/js/main.js"></script><script src="/zhuxiaodong.gitee.io/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div><div class="aplayer no-destroy" data-id="3136952023" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true"> </div><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="true"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/zhuxiaodong.gitee.io/js/search/local-search.js"></script></div></body></html>